<html>

<head>
    <title>控制器配置</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>

<body>
    <h2>ESP32 LED 控制器</h2>
    <form action="/config-submit" method="post" onsubmit="return validateForm()">
        <legend>连接到的Wifi热点名称(SSID)</legend>
        <input type="text" placeholder="连接到的Wifi热点名称(SSID)" name="ssid" value="ETT_STA_SSID"></input>
        <legend>设置要连接到Wifi热点的密码</legend>
        <input id="password" type="password" placeholder="Wifi热点密码" name="password" pattern="[\w]{8,}"></input>
        <legend>设置该控制器的名称</legend>
        <input type="text" placeholder="设置名称" name="name" value="ETT_NAME"></input>
        <legend>本系统作为</legend>
        <select id="role" name="role">
            <option value="ground-control" ETT_AS_GND_CTRL>地面系统控制（道岔、信号灯等）</option>
            <option value="locomotive-control" ETT_AS_LOCO_CTRL>机车控制</option>
        </select>
        <legend></legend>
        <input type="submit" value="提交"></input>
    </form>
    <script>
        function validateForm() {
            var txtPassword = document.getElementById('password');
            if (txtPassword.value.length < 8) {
                alert('密码长度必须>=8位！');
                return false;
            }
            return true;
        }
    </script>
    <style>
        .button-control {
            width: 100px;
        }

        legend {
            margin-top: 12px;
        }

        input {
            margin-top: 6px;
        }

        select {
            margin-top: 6px;
        }
    </style>
</body>

</html>
